//global info about the light
uniform vec3 light_position;
uniform vec3 light_color;
uniform mat4 modelt;

//this will store the color for the pixel shader
varying vec3 pixel_color;
varying vec3 normal;
void main()
{	
	gl_TexCoord[0] = gl_MultiTexCoord0;
	
	//calcule the normal in camera space (the NormalMatrix is like ViewMatrix but without traslation)
	normal = (modelt * vec4(gl_Normal,1.0)).xyz;
	
	//calcule the vertex in object space
	vec3 pixel_pos = (gl_ModelViewMatrix * gl_Vertex).xyz;

	//calcule the light_vector using the light position in camera space
	vec3 light_vector = (gl_ModelViewMatrix * vec4(light_position,1)).xyz - pixel_pos;
	
	//normalize the light vector
	light_vector = normalize(light_vector);
	
	//calcule the NdotL
	float NdotL = dot (light_vector, normal);
	
	//avoid negative values
	if (NdotL < 0.0) NdotL = 0.0;
	
	//store the color in the varying var to use it from the pixel shader
	pixel_color = NdotL * light_color;
	
	//calcule the position of the vertex using the matrices
	gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
}